Skip to content

Block Editor: Bail out of hasSelectedInnerBlock when there is no clientId - #81315

Merged
Mamaduka merged 1 commit into
trunkfrom
fix/has-selected-inner-block-selector
Aug 7, 2026
Merged

Block Editor: Bail out of hasSelectedInnerBlock when there is no clientId#81315
Mamaduka merged 1 commit into
trunkfrom
fix/has-selected-inner-block-selector

Conversation

@Mamaduka

@Mamaduka Mamaduka commented Aug 7, 2026

Copy link
Copy Markdown
Member

What?

Related #81210 and #81212

A small code quality improvement, after I realized it's better to handle this case in the selector 😅

hasSelectedInnerBlock returned false for a missing client ID, but only after reading the selection and either walking it or checking it against the ancestor set. Neither can ever match, so return false up front instead.

This also fixes the root client ID (''), which the shallow check reported as true whenever any top-level block was selected, while the deep check reported false. Both now return false. No caller passes '' today.

I've also cleaned up checks from #81210.

Testing Instructions

CI checks are green.

Use of AI Tools

Assisted by Claude.

@Mamaduka Mamaduka self-assigned this Aug 7, 2026
@Mamaduka
Mamaduka requested a review from ellatrix as a code owner August 7, 2026 07:04
@Mamaduka Mamaduka added [Type] Code Quality Issues or PRs that relate to code quality [Package] Block editor /packages/block-editor labels Aug 7, 2026
@Mamaduka
Mamaduka force-pushed the fix/has-selected-inner-block-selector branch from ffbe4d5 to 5fe0d0d Compare August 7, 2026 07:05
@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>
Co-authored-by: im3dabasia <im3dabasia1@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@Mamaduka
Mamaduka force-pushed the fix/has-selected-inner-block-selector branch from 5fe0d0d to eae1ed7 Compare August 7, 2026 07:05
@Mamaduka
Mamaduka requested review from talldan and youknowriad August 7, 2026 07:08
@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown

Size Change: +1 B (0%)

Total Size: 7.82 MB

📦 View Changed
Filename Size Change
build/scripts/block-editor/index.min.js 434 kB +1 B (0%)

compressed-size-action

@im3dabasia im3dabasia left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR!

✅ LGTM

Comment thread packages/block-editor/CHANGELOG.md Outdated
@Mamaduka
Mamaduka force-pushed the fix/has-selected-inner-block-selector branch from eae1ed7 to 72c59ed Compare August 7, 2026 08:38
@Mamaduka
Mamaduka merged commit a8adbd7 into trunk Aug 7, 2026
45 of 46 checks passed
@Mamaduka
Mamaduka deleted the fix/has-selected-inner-block-selector branch August 7, 2026 11:17
@github-actions github-actions Bot added this to the Gutenberg 23.8 milestone Aug 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Package] Block editor /packages/block-editor [Type] Code Quality Issues or PRs that relate to code quality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants